1. Field of the Invention
The invention relates to the field of computer systems. More specifically, the invention relates to a system for providing the absolute difference of unsigned values.
2. Background Information
Multimedia applications (e.g., applications targeted at computer supported cooperation (CSC--the integration of teleconferencing with mixed media data manipulation), 2D/3D graphics, image processing, video compression/decompression, recognition algorithms and audio manipulation) require the manipulation of large amounts of data which may be represented in a small number of bits. For example, graphical data typically requires 8 bits and sound data typically requires 16 bits. Each of these multimedia application requires one or more algorithms, each requiring a number of operations. For example, an algorithm may require an add, compare and shift operations.
To improve efficiency of multimedia applications (as well as other applications that have the same characteristics), prior art processors provide packed data formats. A packed data format is one in which the bits typically used to represent a single value are broken into a number of fixed sized data elements, each of which represents a separate value. For example, a 64-bit register may be broken into two 32-bit elements, each of which represents a separate 32-bit value. In addition, these prior art processors provide instructions for separately manipulating each element in these packed data types in parallel. For example, a packed add instruction adds together corresponding data elements from a first packed data item and a second packed data item. Thus, if a multimedia algorithm requires a loop containing five operations that must be performed on a large number of data elements, it is desirable to pack the data and perform these operations in parallel using packed data instructions. In this manner, these processors can more efficiently process multimedia applications.
In performing video conferencing in multimedia applications, video data from a camera is first encoded. The encoded data is then transmitted though a channel (a CD ROM, disk) to be processed by a decoder. The decoder then outputs frame information to be displayed. The encoding typically requires the step of performing a motion estimation. Motion estimation is the process of estimating displacement of the moving objects in a video sequence. Such estimation requires searching for the best matches between data sets of a given current frame and a given reference frame, where a current frame is what is displayed at the present and a reference frame is what needs to be displayed. The sum of absolute differences is commonly used for such estimation. The displacement information is used to interpolate missing frame data or to improve the performance of compression algorithms. The searching step is typically performed by using conventional scalar mechanism to calculate the sum of absolute differences. This is performed by subtracting each pixel value in the current frame from its corresponding pixel in the reference frame, taking the absolute value of the result. This may involve a branch operation and summing the results into an accumulator.
The conventional scalar mechanism of performing a search for matching data sets using branching operations leads to sacrificing processing speed by paying for branch prediction penalties. More specifically, some implementations for performing branching operations try to speed up execution by attempting to reduce pipeline penalties that can result from branches by speculatively predicting where branches will go with either compile-time schemes (e.g. predict-not-taken or predict-taken) or hardware schemes (e.g. branch-prediction buffer). If a prediction is correct, the proper instruction will have been fetched and decoded in advance and there is a potential for a gain in performance. However, if a prediction is wrong, performance is lost. For example, assume the prediction scheme has predicted that the branch will be taken in the above pseudo code representation and further assume that the branch condition is not actually met. By the time the branch condition is evaluated, the pipeline already contains the decoded STORE X,C instruction. Thus, when the branch condition is determined to be false, the correct instruction (the STORE X,B instruction) must be fetched and decoded, effectively causing the pipeline to stall. This example illustrates the uncertain nature of branches based on data. The inherent problem with this technique is that branches on data are poorly predicted by branch prediction schemes. As a result, branch prediction penalties are frequently paid in situations similar to the one illustrated above.
Thus, a limitation of this and other prior methods of performing searches for matching data in motion estimation using branching operations, is the high cost to performance due to mispredicted branches. The processing time required to perform such branching operation increases the overall processing time. Therefore, it is desirable to incorporate in a computer system a method and an apparatus for performing the searching step required in motion estimation without the need for branching and therefore without having to sacrifice processing speed.